<template>
	<el-main class="sc-page">
		<el-alert class="page-msg" description="全文检索设置需在系统正式使用前设置完成，否则在设置之前的附件文件将无全文检索索引" type="warning" show-icon :closable="false"/>
		<el-card shadow="never" header="所有模块附件列表">
			<scTable ref="table" :apiObj="apiObj" height="auto" row-key="recordId" stripe>
				<el-table-column label="序号" prop="sortNo" width="50"></el-table-column>
				<el-table-column label="功能模块" prop="name" width="100"></el-table-column>
				<el-table-column label="模块标识" prop="module" width="100"></el-table-column>
				<el-table-column label="当前状态" prop="status" width="100">
					<template #default="scope">
						<el-tag type="danger" v-if="scope.row.status=='0'">已停用</el-tag>
						<el-tag type="success" v-if="scope.row.status=='1'">已启用</el-tag>
					</template>
				</el-table-column>
				<el-table-column label="备注" prop="remark" min-width="400"></el-table-column>
				<el-table-column label="操作" width="70">
					<template #default="scope">
						<el-dropdown>
							<el-button icon="el-icon-more" size="small"></el-button>
							<template #dropdown>
								<el-dropdown-menu>
									<el-dropdown-item v-if="scope.row.status=='0'" @click="setSysLuceneConfig(scope.row.recordId,scope.row.status)">启用</el-dropdown-item>
									<el-dropdown-item v-if="scope.row.status=='1'" @click="setSysLuceneConfig(scope.row.recordId,scope.row.status)">停用</el-dropdown-item>
								</el-dropdown-menu>
							</template>
						</el-dropdown>
					</template>
				</el-table-column>
			</scTable>
		</el-card>
	</el-main>
</template>

<script>
export default {
	name: 'Lucene Setting',
	data() {
		return {
			apiObj: this.$API.system.sysLuceneConfig.getAllSysLuceneConfig
		}
	},
	methods:{
		async setSysLuceneConfig(recordId,status)
		{
			if(status=="0")
			{
				status = status=="0"?"1":"0"
			}else if(status=="1")
			{
				status = status=="1"?"0":"1"
			}
			var params={
				recordId:recordId,
				status:status
			}
			const loading = this.$loading();
			var res = await this.$API.system.sysLuceneConfig.setSysLuceneConfig.post(params);
			if (res.code == 200) {
				this.$refs.table.refresh()
				this.$message.success(res.message)
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
			loading.close();
		}
	}
}
</script>

<style scoped>
.page-msg {
	margin: 15px 0;
}

.page-buttons {
	margin-bottom: 20px;
}
</style>
